package com.itheima.config;

import com.alibaba.csp.sentinel.adapter.servlet.callback.WebCallbackManager;
import org.springframework.context.annotation.Configuration;

import javax.annotation.PostConstruct;

@Configuration
public class SentinelConfig {
    @PostConstruct
    public void init() {
        WebCallbackManager.setRequestOriginParser(request ->
                request.getRemoteAddr());//设置获取请求地址的逻辑

        //设置阻塞后需要执行的逻辑
        WebCallbackManager.setUrlBlockHandler((request, response, e) ->
                response.getWriter().println("block:" + request.getRemoteAddr()));
    }
}